<include file="../header" />
<body class="J_scroll_fixed">
    
    <script>
         function coachStatistics(year,month){
             var coachId = $("input[name=coachId]").val();
             
            $.ajax({
                    type: "post",
                    url: "{:U('coach/coachStatistics')}",
                    data: {year:year, month:month,coachId:coachId},
                    dataType: "json",
                    success: function(data){
//                        layer.msg('sc--->'+data['saleCount']+","+'sa--->'+data['saleAmount']+","+'cc--->'+data['courseCount']+","+'ca--->'+data['courseAmount']);
                       $('input[name=saleCount]').val(data['saleCount']);
                       $('input[name=saleAmount]').val(data['saleAmount']);
                       $('input[name=courseCount]').val(data['courseCount']);
                       $('input[name=courseAmount]').val(data['courseAmount']);
                    },
                    error:function(){
                        layer.msg('request error..');
                    }
                });
        }
        $(document).ready(function() {
            var year = $('select[name=year]').val();
            var month = $('select[name=month]').val();
            
  
            
            $('select[name=year]').change(function() {

                var year = $(this).val();
                var month = $('select[name=month]').val();
                $('#fyear').val(year);
                $('#fmonth').val(month)
                $('#ymform').submit();
                
            });
             $('select[name=month]').change(function() {

                var month = $(this).val();
                var year = $('select[name=year]').val();
                $('#fyear').val(year);
                $('#fmonth').val(month)
                $('#ymform').submit();
                
            });
            
            $('input[name=salePercentage]').keyup(function() {
                

                var salePercentage = $(this).val();
                
                 //正则判断是否为数字
                if(!/^[0-9]+$/.test(salePercentage)) {
                    layer.msg('卖课提成应为数字!');
                    return false;
                }
   
            });
            $('input[name=coursePercentage]').keyup(function() {
                
                
                var coursePercentage = $(this).val();
                
                 //正则判断是否为数字
                if(!/^[0-9]+$/.test(coursePercentage)) {
                    layer.msg('上课提成应为数字!');
                    return false;
                }
                
            });

            $('button#send').click(function () {

                var year = $('select[name=year]').val();
                var month = $('select[name=month]').val();
                var salePercentage = $('input[name=salePercentage]').val();
                var coursePercentage = $('input[name=coursePercentage]').val();
               
                if(year == 0 || month == 0 ) {
                    layer.msg('请选择年份和月份，不能为空!');
                    return false;
                }
                
                if(!/^[0-9]+$/.test(salePercentage)||salePercentage===''||salePercentage===null) {
                    layer.msg('卖课提成应为数字!!');
                    return false;
                }
                 //正则判断是否为数字
                if(!/^[0-9]+$/.test(coursePercentage)||coursePercentage===''||coursePercentage===null) {
                    layer.msg('上课提成应为数字!!');
                    return false;
                }else{
                    $("#form").submit();
                }
               
               
            });
           
        });

    </script>
    <form id="ymform" class="well form-search" method="post" style="float:left;width:100%;" action="{:U('coach/coachPerform')}">
    <div class="search_type cc mb10">
        <input type="hidden" name="coachId" value="{$coachId}"/>
        <div class="mb10">
        <span class="mr20">
            年份选择：
            {:getYearOrMonthSelectHtml($year,2015,2020, 0,'year')}
            月份选择：
            {:getYearOrMonthSelectHtml($month,1,12, 0,'month')}
        </span>
        </div>
    </div>
</form>
 <div class="wrap J_check_wrap">
     <table class="table table-hover table-bordered">
         <thead>
             <tr>
            <th colspan="5">卖课提成详细</th>       
            </tr>
        <tr>           
            <th>教练</th>
            <th>卖课数</th>
            <th>总销售业绩</th>
            <th>金额提成</th>
            <th>比率提成</th>
        </tr>
        </thead>
        <tbody>
        <td>{$data.sale.coach_name}</td>
        <td>{$data.sale.sale_count} 节</td>
        <td>{$data.sale.sale_amount} 元</td>
        <td>{$data.sale.sale_commission} 元</td>
        <td>{$data.sale.rate_commission} 元</td>
        </tbody>
     </table>
     <table class="table table-hover table-bordered">
         <thead>
             <tr >
            <th colspan="4">上课提成详细</th>       
            </tr>
        <tr>           
            <th>教练</th>
            <th>上课数</th>
            <th>金额提成</th>
            <th>比率提成</th>
        </tr>
        </thead>
        <tbody>
        <td>{$data.sale.coach_name}</td>
        <td>{$data.course.courseNumber} 节</td>
        <td>{$data.course.courseComm} 元</td>
        <td>{$data.course.courseRateComm} 元</td>
        </tbody>
     </table>
    <table class="table table-hover table-bordered">
        <thead>
        <tr>
            <th>编号</th>
            <th>店铺名称</th>
            <th>教练</th>
            <th>会员</th>
            <th>课程单价</th>
            <th>数量</th>
            <th>小计</th>
            <th>上课数</th>
            <th>金额提成</th>
            <th>比率提成</th>
        </tr>
        </thead>
        <tbody>
        <?php $id=1;?>
        <foreach name="list" item="vo">
            <tr>
                <td>{$id++}</td>
                <td>{$vo.shop_name}</td>
                <td>{$vo.coach_name}</td>
                <td>{$vo.vip_name}</td>
                <td>{$vo.price} 元</td>
                <td>{$vo.number} 节</td>
                <td>{$vo.total_amount} 元</td>
                <td>{$vo.course_num} 元</td>               
                <td>{$vo.course_commission} 元</td>
                <td>{$vo.course_rate_commission} 元</td>
            </tr>
        </foreach>
        </tbody>
    </table>
    <div class="pagination">{$page}</div>
</div>	    
    <script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>